package com.itxckf.mapper;

import com.itxckf.pojo.Role;
import com.itxckf.pojo.RolePath;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface RoleMapper {
    @Select("select * from permissions")
    List<Role> getRole();

    @Select("SELECT Paths.PathID, Paths.PathName, Paths.Description FROM Users JOIN Roles ON Users.role = Roles.RoleID JOIN RolePaths ON Roles.RoleID = RolePaths.RoleID JOIN Paths ON RolePaths.PathID = Paths.PathID WHERE Users.UserID = #{id}")
    List<RolePath> getUserRole(Short id);


    @Select("SELECT * from Paths")
    List<RolePath> getPaths();

    @Insert("INSERT INTO Paths (PathName, Description) VALUES (#{pathName}, #{description})")
    void addPath(RolePath rolePath);


    @Delete("DELETE FROM Paths WHERE PathID = #{id}")
    void deletePath(Short id);

    void editUserRole(@Param("roleID") Short roleID, @Param("newIds") List<Short> newIds);



    @Delete("DELETE FROM RolePaths WHERE RoleID = #{roleID};")
    void deleteUserRole(@Param("roleID") Short roleID);



    void editPath(RolePath rolePath);
}
